<template>
            <el-collapse-item title="单点选择页面" name="selectitem">
                <div  >
                    <div style="width: 150px;" >数据点：</div>
                    <el-input v-model="curComponent.hg3000.linkid.descr" ></el-input>
                </div>
                <div class="clsButton" >
                    <el-button type="primary"  @click="resetItem" >置空</el-button>
                    <el-button type="primary"  @click="selectItem" style="margin: 0 10px 0 10px;" >选择点</el-button>
                    <DlgSelectItem  ref="refselectitem"  :dialog-visible="dlgVisible"  @res-select-item="handleSelectItem"  ></DlgSelectItem>
                </div>
            </el-collapse-item>
</template>

<script>
import { mapState } from 'vuex'
import DlgSelectItem from './DlgSelectItem.vue';

export default {
    components: {  DlgSelectItem },
    data() {
        return {
            dlgVisible: false, 
        }
    },
    computed: mapState([
        'curComponent',
        'prefix',
    ]),
    methods: {
        selectItem(  ){
            this.$refs.refselectitem.init( this.curComponent.hg3000.linkid )
            this.dlgVisible = true  //弹对话框进行点选择
        },

        handleSelectItem( code , result   ){
            if( code == 1 ) {
                console.log("result:", result)
                this.curComponent.hg3000.linkid =  JSON.parse( JSON.stringify(result)  ) 
                console.log("lindid:  ", this.curComponent.hg3000.linkid )
                if (  typeof this.curComponent.propValue == "string" )
                    this.curComponent.propValue = result.key.replace( this.prefix+"-",  "" )    //同一个项目不重复显示啦
            }
            this.dlgVisible = false
        },

        resetItem( ){
            this.curComponent.hg3000.linkid = {}
        }
        
    },
}
</script>

<style lang="scss" scoped>
.clsButton {
    display: flex;
    flex-direction:  row-reverse ;
    align-items: center;

}

.clsOneDot span {
    width: 250px;
    text-align: left;
    margin-left: 20px;
}

.list {
        height: 30px;
        cursor: grab;
        text-align: center;
        color: #333;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 12px;
        padding: 0 10px;
        position: relative;
        user-select: none;

        .icon-container {
            .iconfont {
                cursor: default;
                font-size: 24px;
            }
        }
}

::v-deep( .el-collapse-item__header ){

  background-color: lightgray;
}
</style>
